package com.example.demo.service;

import com.example.demo.mapper.MessageMapper;
import com.example.demo.model.Message;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class MessageService {
    @Autowired
    private MessageMapper messageMapper;
    public List<Message> getMessage() {
        return messageMapper.selectAll();
    }

    public Integer addMessage(Message message) {
        try {
            log.info("添加留言信息：message{}",message);
            Integer result=messageMapper.insertMessage(message);
            return result;
        }catch (Exception e){
            log.error("添加留言失败：e： {}",e);
            return null;
        }
    }
}
